<template>
       
     <div class="recharge">

        <div class="header"><van-nav-bar title="兑换" left-text="返回"  @click-left="$router.go(-1)"  left-arrow/></div>

        <div class="transfer">
            <div title>
                <div><img :src="require('../../assets/img/home_5.png')"  /><span>AZC</span></div>
                <div>拥有：<span v-html="list.usdtnumber"></span>USDT</div>
            </div>
            <div put>
                <div last >≈{{list.CNY}} CNY<br/> ≈{{list.AZC}} AZC</div>
                <div>
                    <van-cell-group>
                        <van-field v-model="count" @input="input_number" placeholder="今日剩余可兑换1000AZC" />
                      </van-cell-group>
                </div>
                <!-- <div point>单笔最小兑换额为50AZC</div> -->
            </div>
        </div>
     
        <div sub> <van-button type="default" @click="sub">确定</van-button></div>

       
     </div>
</template>

<script>

export default {

data() {
    return {
            count:0,
            list:{},
    }
},
mounted() { 
   var that=this;
  
    that.base.head_status()
     that.show();
     

},

 methods: {
     input_number(){
         let that=this;
         that.count = that.count.replace(/\D/g, '')
     },
   
    show(){
              let that=this;
               var data={token:JSON.parse(localStorage.userinfo).token}
              
                       that._API.getExchange(data).then(res => {
                            if(res.code==200){
                                 
                                  that.list=res.data;
                            }
                           
                        }).catch(err => {
                            console.log("err", err);
                        });
    },
    sub(){
        let that=this;
        if(that.count<1){
            return  that.$toast({ message: "单笔最小兑换额为1USDT"});
        }

        that.$router.push({name:'verif_pwd',params:{type:'exchange','usdtnumber': that.count}})
        return
         that.$dialog.confirm({ title: '提示信息',message: '确定要把USDT兑换成AZC吗'}).then(() => {

            var data={token:JSON.parse(localStorage.userinfo).token,"usdtnumber": that.count}

                        that.$toast.loading({ message: '加载中...', forbidClick: true,overlay:true});
                        that._API.exchange(data).then(res => {
                             that.$toast.clear();
                                if(res.code==200){
                                    that.count=0;
                                    that.$dialog.alert({title: '提示信息', message: res.msg }).then(() => {
                                              //  that.show();
                                        });
                                        return
                                }
                                that.$dialog.alert({title: '提示信息', message: res.msg }).then(() => {});
                            }).catch(err => {
                               
                                tant.$dialog.alert({title: '提示信息', message:"网络请求失败,请稍后再试"}).then(() => {});
                               
                            });
          
            }).catch(() => {
            // on cancel
            });
    }
 
       
     


}
}
</script>


<style lang="scss" scoped >


   
       .van-nav-bar,.transfer .van-cell-group,.transfer .van-cell{background-color: initial;}
    .header *,.van-nav-bar .van-icon,.transfer *,.transfer /deep/.van-field__control::-webkit-input-placeholder,/deep/.van-field__control{color:white}


    .recharge [sub]{text-align: center;}
    .recharge [sub] .van-button{background-color: #831BFA;color: white;border:0;border-radius: 3rem;width: 90%;}

    .transfer{margin: 1rem;padding: 1rem;    border-radius: .3rem; box-shadow: inset 0 0 1rem 0px #7b00ff;}   
    .transfer [title]{display: flex;align-items: center;}
    .transfer [title]>div:nth-child(1){flex:1;display: flex;align-items: center;}
    .transfer [title]>div:nth-child(2),.transfer [title]>div:nth-child(2)>span{color:#00C6FF}
    .transfer [title] span{padding-left: .5rem;}

    .transfer [put]{margin-top: 1rem;}
    .transfer [put] [last]{font-size: 0.7rem;    position: absolute; float: right;   right: 2rem;}
    .transfer [put]>div:nth-child(2){border-bottom: 1px solid #615959;}
    .transfer [point]{font-size: 0.7rem;text-align: right;color:#a0a0a0;margin-top: .5rem;}








       
</style>
